import javax.swing.plaf.synth.SynthDesktopIconUI;

public class Teacher {
    private String name;
    Student[] students = new Student[0];
    public Teacher(String name){
        this.name = name;
    }
    public void addStudent(Student student) {
        Student[] newStudents = new Student[students.length+1];
        System.arraycopy(students,0,newStudents,0,students.length);
        newStudents[students.length] = student;
        students = newStudents;
    }

    public void printInfo() {
        //String studentInfo;
        StringBuilder studentInfo = new StringBuilder();
        for(Student stu: students) {
            studentInfo.append(String.format("Student name: %s \nStudent grade: %d",stu.getName(),stu.grade));
        }
        System.out.println("Teacher: "+name);
        System.out.println(studentInfo);
    }
}
